<?php
namespace app\api\model;

use think\Model;
use think\Db;

class CourseModel extends Model
{
    function coursedetail($courseid) {
        $course =  db('course')->where('courseid', $courseid)->find();
        return ['coursedetail'=>$course];
    }
    function courselist() {
        $course =  db('course')->select();
        return ['courselist'=>$course];
    }
    function courseenroll($userid, $courseid) {
        $data=[
            'userid'=>$userid,
            'courseid'=>$courseid,
        ];
        $result=Db::name('course_enroll')->insert($data);
        if($result){
            return  ['success'=>1];

        }else{
            return  ['success'=>0];
        }
    }
}